#include "virt_disk.h"
#include "string.h"

extern char sdisk[];
extern char edisk[];

/**
 * @brief: read single/multiple sector(s) from virtual disk
 * @param data_buff: pointer to the buffer that receives the data read from the SD.
 * @param sector: disk's internal address to read from.
 * @param count: count of sectors to be read
 * @return: The disk Response:
 *         - 0xFF: Sequence failed
 *         - 0: Sequence succeed
 */
uint8_t disk_read_sector(uint8_t *data_buff, uint32_t sector, uint32_t count) {
	// exceed disk capacity
	if ((uint64)sdisk + (sector + count) * SECSIZE > (uint64)edisk) {
		return 0xff;
	}
	memcpy((void *)data_buff, sdisk + sector * SECSIZE, (size_t)count * SECSIZE);
	return 0;
}

/**
 * @brief: write single/multiple sector(s) from virtual disk
 * @param data_buff: pointer to the buffer to be written to the disk.
 * @param sector: disk's internal address to write to.
 * @param count: count of sectors to be written
 * @return: The disk Response:
 *         - 0xFF: Sequence failed
 *         - 0: Sequence succeed
 */
uint8_t disk_write_sector(uint8_t *data_buff, uint32_t sector, uint32_t count) {
	return 0;
}
